#ifndef GAME_WINDOW_H
#define GAME_WINDOW_H

#include "game_widget.h"
#include "socket_helper.h"

#include <QDialog>
#include <QVBoxLayout>
#include <QLayout>
#include <QTextEdit>
#include <QLineEdit>
#include <functional>

class GameWindow : public QDialog,public GameHelper
{
    Q_OBJECT
private :
    std::unique_ptr<TabaleData> m_table_data;
    QString m_chat_content;

    void set_message_to_widget(const TabaleData &data);

    QHBoxLayout *container;

    QVBoxLayout *container_chat;
    QTextEdit *label_chat;
    QLineEdit *edit_input;
    QPushButton *button_chat;

    FrameLayout *container_game;

    CardPlayWidget *cards3_widget;

    TableOtherUserWidget *prev_player_widget;
    TableSelfWidget *current_player_widget;
    TableOtherUserWidget *next_player_widget;


    int my_index() const
    {
        return table_index;
    }

    int my_prev_index() const
    {
        return (table_index+3-1)%3;
    }

    int my_next_index() const
    {
        return (table_index+1)%3;
    }

public:
    GameWindow(QWidget *parent,QWebSocket *socket,int id,int index);
    ~GameWindow();

protected:
    void on_send_clicked(bool);

    void on_game_response_error(const int &code,const int &rep_code,const QString &rep_message,const QString &tag)override;

    void on_add_table_message(const TabaleData &data)override;

    void on_prepare_table_message(const TabaleData &data)override;

    void on_rob_table_message(const TabaleData &data)override;

    void on_cards_table_message(const TabaleData &data) override;

    void on_chat_table_message(const ChatTableData &data)override;

    void closeEvent(QCloseEvent *e) override;

    void on_message(const QString &message) override;

    void on_message(const QByteArray &message)override;

    void on_disconnect()override;

    void on_connected()override;
public:
    void on_prepare_clicked(bool prepare);

    void on_rob_clicked(bool rob);

    void on_cards_clicked(const QVector<dymy::CARD_t> &cards);

    void on_no_cards_clicked();
signals:

public slots:
};

#endif // GAME_WINDOW_H
